package at.ac.big.tuwien.ewa.picasa;

import java.net.URL;
import java.util.ArrayList;
import java.util.List;

import com.google.gdata.client.photos.PicasawebService;
import com.google.gdata.data.*;
import com.google.gdata.data.photos.AlbumEntry;
import com.google.gdata.data.photos.AlbumFeed;
import com.google.gdata.data.photos.GphotoEntry;
import com.google.gdata.data.photos.PhotoEntry;
import com.google.gdata.data.photos.UserFeed;
public class PicasaConnectorImpl implements PicasaConnector {

	@Override
	public List<Avatar> getPhotoURLs() throws Exception {
		URL feedUrl = new URL("https://picasaweb.google.com/data/feed/api/user/111420671758947023853/albumid/5708523142385535377");
		PicasawebService service = new PicasawebService("madn");
		List<Avatar> avatare = new ArrayList<Avatar>();
		
		AlbumFeed albumFeed = service.getFeed(feedUrl, AlbumFeed.class);

		for (PhotoEntry photo : albumFeed.getPhotoEntries()) {
			Avatar avatar = new Avatar();
			avatar.setUrl(photo.getMediaContents().get(0).getUrl());	
//			System.out.println(photo.getMediaContents().get(0).getUrl());
			avatar.setName(photo.getTitle().getPlainText().split("\\.")[0]);
			avatare.add(avatar);
		}
		return avatare;
	}

}


